home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntlb20 / lib / gcrt0.s < prev    next >
Text File  |  1992-03-17  |  2KB  |  70 lines

  1. | gcrt0.o: linked in when profiling is enabled
  2. |
  3. | Initilization code; this is common to both 16 and 32 bit libraries,
  4. | so be careful!
  5. |
  6.     .globl    __app        | short, declared in crtinit.c
  7.     .globl    __base        | BASEPAGE *, declared in crtinit.c
  8.     .globl    __heapbase    | void *
  9.     .globl    __stksize    | long, declared by user or in stack.c
  10.  
  11. |
  12. | Assumption: programs always start with a0 == 0, accessories with
  13. | a0 == basepage
  14. |
  15.     .text
  16.     .even
  17.     .globl    __start
  18. __start:
  19.     subl    a6, a6        | clear a6 for debuggers
  20.     cmpw    #0, a0        | test if acc or program
  21.     beq    __startprg    | if a program, go elsewhere
  22.     movel    a0, __base    | acc basepage is in A0
  23.     lea    a0@(252), sp    | use command line as a temporary stack
  24.     jmp    __acc_main    | function is in crtinit.c
  25. |
  26. | program startup code: doesn't actually do much, other than push
  27. | the basepage onto the stack and call _start1 in crtinit.c
  28. |
  29. __startprg:
  30.     movel    sp@(4), a0    | get basepage
  31.     movel    a0, __base    | save it
  32.     movel    a0@(4), d0    | get _base->p_hitpa
  33.     andl    #0xfffffffe, d0    | round off
  34.     movel    d0, sp        | set stack (temporarily)
  35.     jmp    __crtinit    | in crtinit.c
  36.  
  37. |
  38. | _setstack: changes the stack pointer; called as
  39. |     void setstack( void *newsp )
  40. | called from crtinit.c once the new stack size has been decided upon
  41. |
  42. | WARNING WARNING WARNING: after you do this, local variables may no longer
  43. | be accessible!
  44. | destroys a0 and a7
  45.  
  46.     .globl    __setstack
  47. __setstack:
  48.     movel    sp@+, a0    | save return address
  49.     movel    sp@+, sp    | new stack pointer
  50.     jmp    a0@        | back to caller
  51.  
  52. |
  53. | interfaces for gprof: for crt0.s, does nothing, but for gcrt0.s branches
  54. | to the appropriate subroutines
  55. |
  56.     .globl    __monstartup
  57.     .globl    _monstartup
  58.     .globl    ___mcleanup
  59.     .globl    __mcleanup
  60.     .globl    __moncontrol
  61.     .globl    _moncontrol
  62.  
  63. __monstartup:
  64.     jmp    _monstartup
  65. __moncontrol:
  66.     jmp    _moncontrol
  67. ___mcleanup:
  68.     jmp    __mcleanup
  69.  
  70.